<template>
  <div class="nation">
    <el-checkbox-group v-model="model.brothersList">
      <el-checkbox label="1" @change="handlerCheckBox('1')">无</el-checkbox>
      <el-checkbox label="2" @change="handlerCheckBox('2')">高血压</el-checkbox>
      <el-checkbox label="3" @change="handlerCheckBox('3')">糖尿病</el-checkbox>
      <el-checkbox label="4" @change="handlerCheckBox('4')">冠心病</el-checkbox>
      <el-checkbox label="5" @change="handlerCheckBox('5')"
        >慢性阻塞性肺疾病</el-checkbox
      >
      <el-checkbox label="6" @change="handlerCheckBox('6')"
        >恶性肿瘤</el-checkbox
      >
      <el-checkbox label="7" @change="handlerCheckBox('7')">脑卒中</el-checkbox>
      <el-checkbox label="8" @change="handlerCheckBox('8')"
        >严重精神障碍</el-checkbox
      >
      <el-checkbox label="9" @change="handlerCheckBox('9')">结核病</el-checkbox>
      <el-checkbox label="10" @change="handlerCheckBox('10')">肝炎</el-checkbox>
      <el-checkbox label="11" @change="handlerCheckBox('11')"
        >先天畸形</el-checkbox
      >
      <el-checkbox label="99" @change="handlerCheckBox('99')">其他</el-checkbox>
      <el-input v-model="model.brothersValue" style="width:120px" />
    </el-checkbox-group>
  </div>
</template>

<script>
export default {
  props: {
    model: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {}
  },
  methods: {
    handlerCheckBox(value) {
      const emptyVal = "1"
      // 1 无 5 其他
      const currentIsChecked = this.model.brothersList.includes(value)
      // 当选择无时
      if (value === emptyVal && currentIsChecked) {
        this.model.brothersList = ["1"]
      } else if (value !== emptyVal) {
        this.model.brothersList = this.model.brothersList.filter(v => v > 1)
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.nation {
  // display: flex;
  .el-input {
    margin-left: 15px;
  }
}
</style>
